package com.joyintech.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.joyintech.feign.BatchService;
import com.joyintech.util.Verify;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Log4j2
@RestController
@RequestMapping("/portal")
public class DataportalController {

    @Autowired
    private BatchService batchService;


    /**
     * 查询资产配置详情
     *
     * @param message
     * @return
     */
    @PostMapping(value = "/getPyResult", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String getPyResult(@RequestBody String message) throws Exception {
        String decMessage = Verify.decMessage(message);

        Map<String, Object> map = JSON.parseObject(decMessage, HashMap.class);

        String result = batchService.getPyResult(map);
        log.info("{}", JSON.toJSONString(result));
        JSONObject jsonObject = JSON.parseObject(result);
        String response = Verify.encMessage(jsonObject.toJSONString());
        return response;
    }


}
